<template>
	<div>
		
		<h1>课程提交</h1>


		<van-cell-group>
        

        <van-uploader :after-read="afterRead" />


      </van-cell-group>


      
      <!--视频控件-->
      <van-cell-group>
        

      	<video width="300" height="240" :src="src" controls="controls" autoplay="autoplay" muted ></video>
      

      </van-cell-group>



	</div>
</template>



<script>

import mycate from './mycate.vue';

export default{

	data(){

		return {

			data:{},
			cid:"",
			src:"",

		}

	},
	components:{
		mycate
	},
	mounted:function(){


		

		//接收参数
		this.cid = this.$route.query.cid;
		console.log('课程分类id是'+this.cid);

	},
	methods:{

		get_data:function(){

			this.axios.get("http://localhost:8000/get_cate/").then((res) => {


				console.log(res);

				var mytree = {'id':0,name:""};

				mytree['children'] = res.data;

				this.data = mytree;


			});



		},

		//文件上传
    afterRead:function(file){


        //定义参数
        let data = new FormData();
        data.append('file',file.file);

        //创建实例
        const axiosInstance = this.axios.create({withCredentials:false});


        axiosInstance({method:'POST',url:"http://localhost:8000/upload/",data:data}).then(res =>{

            console.log(res);
            this.src = "http://localhost:8000/static/upload/" + res.data.filename;

        });


    }


	}

}
	


</script>


<style>
	



</style>